home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / OSA.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  53.5 KB  |  1,468 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OSA.p
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1992-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT OSA;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __OSA__}
  28. {$SETC __OSA__ := 1}
  29.  
  30. {$I+}
  31. {$SETC OSAIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __ERRORS__}
  35. {$I Errors.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __APPLEEVENTS__}
  38. {$I AppleEvents.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __AEOBJECTS__}
  41. {$I AEObjects.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __COMPONENTS__}
  44. {$I Components.p}
  45. {$ENDC}
  46.  
  47.  
  48. {$PUSH}
  49. {$ALIGN MAC68K}
  50. {$LibExport+}
  51.  
  52. {*************************************************************************
  53.     Types and Constants
  54. *************************************************************************}
  55.  
  56. {    The componenent manager type code for components that
  57.         support the OSA interface defined here. }
  58. { 0x6f736120 }
  59.  
  60. CONST
  61.     kOSAComponentType            = 'osa ';
  62.  
  63. { 0x73637074 }
  64.     kOSAGenericScriptingComponentSubtype = 'scpt';
  65.  
  66. {    Type of script document files.    }
  67. { 0x6f736173 }
  68.     kOSAFileType                = 'osas';
  69.  
  70. {
  71.         Suite and event code of the RecordedText event. 
  72.         (See OSAStartRecording, below.)
  73.     }
  74. { 0x61736372 }
  75.     kOSASuite                    = 'ascr';
  76.  
  77. { 0x72656364 }
  78.     kOSARecordedText            = 'recd';
  79.  
  80. { Selector returns boolean }
  81. { 0x6d6f6469 }
  82.     kOSAScriptIsModified        = 'modi';
  83.  
  84. { Selector returns boolean }
  85. { 0x63736372 }
  86.     kOSAScriptIsTypeCompiledScript = 'cscr';
  87.  
  88. { Selector returns boolean }
  89. { 0x76616c75 }
  90.     kOSAScriptIsTypeScriptValue    = 'valu';
  91.  
  92. { Selector returns boolean }
  93. { 0x636e7478 }
  94.     kOSAScriptIsTypeScriptContext = 'cntx';
  95.  
  96. { Selector returns a DescType which may be passed to OSACoerceToDesc }
  97. { 0x62657374 }
  98.     kOSAScriptBestType            = 'best';
  99.  
  100. {
  101.         This selector is used to determine whether a script has source 
  102.         associated with it that when given to OSAGetSource, the call will not
  103.         fail.  The selector returns a boolean.
  104.     }
  105. { 0x67737263 }
  106.     kOSACanGetSource            = 'gsrc';
  107.  
  108.  
  109.     typeOSADialectInfo            = 'difo';                        {   0x6469666f    }
  110.     keyOSADialectName            = 'dnam';                        {   0x646e616d    }
  111.     keyOSADialectCode            = 'dcod';                        {   0x64636f64    }
  112.     keyOSADialectLangCode        = 'dlcd';                        {   0x646c6364    }
  113.     keyOSADialectScriptCode        = 'dscd';                        {   0x64736364    }
  114.  
  115.  
  116. TYPE
  117.     OSAError                            = ComponentResult;
  118. { Under the Open Scripting Architecture all error results are longs }
  119.     OSAID                                = UInt32;
  120. {
  121.         OSAIDs allow transparent manipulation of scripts associated with
  122.          various scripting systems.
  123.     }
  124.  
  125. CONST
  126.     kOSANullScript                = 0;
  127.  
  128. { No -script constant. }
  129.     kOSANullMode                = 0;                            {  sounds better  }
  130.     kOSAModeNull                = 0;                            {  tastes consistent  }
  131.  
  132. {
  133.         Some routines take flags that control their execution.  This constant
  134.         declares default mode settings are used.
  135.     }
  136.  
  137. TYPE
  138. {$IFC TYPED_FUNCTION_POINTERS}
  139.     OSACreateAppleEventProcPtr = FUNCTION(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT): OSErr;
  140. {$ELSEC}
  141.     OSACreateAppleEventProcPtr = ProcPtr;
  142. {$ENDC}
  143.  
  144. {$IFC TYPED_FUNCTION_POINTERS}
  145.     OSASendProcPtr = FUNCTION({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT): OSErr;
  146. {$ELSEC}
  147.     OSASendProcPtr = ProcPtr;
  148. {$ENDC}
  149.  
  150.     OSACreateAppleEventUPP = UniversalProcPtr;
  151.     OSASendUPP = UniversalProcPtr;
  152.  
  153. CONST
  154.     uppOSACreateAppleEventProcInfo = $000FEFE0;
  155.     uppOSASendProcInfo = $003FEFE0;
  156.  
  157. FUNCTION NewOSACreateAppleEventProc(userRoutine: OSACreateAppleEventProcPtr): OSACreateAppleEventUPP;
  158.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  159.     INLINE $2E9F;
  160.     {$ENDC}
  161.  
  162. FUNCTION NewOSASendProc(userRoutine: OSASendProcPtr): OSASendUPP;
  163.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  164.     INLINE $2E9F;
  165.     {$ENDC}
  166.  
  167. FUNCTION CallOSACreateAppleEventProc(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT; userRoutine: OSACreateAppleEventUPP): OSErr;
  168.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  169.     INLINE $205F, $4E90;
  170.     {$ENDC}
  171.  
  172. FUNCTION CallOSASendProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT; userRoutine: OSASendUPP): OSErr;
  173.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  174.     INLINE $205F, $4E90;
  175.     {$ENDC}
  176. {*************************************************************************
  177.     Standard Script Errors
  178. **************************************************************************
  179.     It is recommended that scripting components use the following set of error
  180.     codes to signal failure when applicable.  This enables applications that
  181.     use the OSA API to deal with some class of script errors in a less than 
  182.     ad hoc manner.  Scripting components are of course encouraged to return
  183.     component-specific errors when these don't apply.
  184. *************************************************************************}
  185. {        Dynamic errors:
  186.  
  187.     These errors result from data-dependent conditions and are typically
  188.     signaled at runtime.
  189. }
  190. {
  191.         Signaled when a value can't be coerced to the desired type. Similar
  192.           to errOSATypeError except results from coercion.
  193.     }
  194.  
  195. CONST
  196.     errOSACantCoerce            = -1700;
  197.  
  198. { Signaled when an object is not found in a container }
  199.     errOSACantAccess            = -1728;
  200.  
  201. {
  202.         Signaled when an object cannot be set in a container.  Same as 
  203.           AERegistry error errAEWriteDenied.
  204.     }
  205.     errOSACantAssign            = -10006;
  206.  
  207. {
  208.         Signaled by user scripts or applications when no actual error code
  209.           is to be returned.  Simply means "an error has occurred".  Most useful
  210.           in conjunction with an error message from the application.
  211.     }
  212.     errOSAGeneralError            = -2700;
  213.  
  214. { Signaled when there is an attempt to divide by zero }
  215.     errOSADivideByZero            = -2701;
  216.  
  217. { Signaled when integer or real value is too large to be represented }
  218.     errOSANumericOverflow        = -2702;
  219.  
  220. {
  221.         Signaled when application can't be launched or when it is remote and
  222.           program linking is not enabled.
  223.     }
  224.     errOSACantLaunch            = -2703;
  225.  
  226. { Signaled when an application can't respond to AppleEvents }
  227.     errOSAAppNotHighLevelEventAware = -2704;
  228.  
  229. { Signaled when an application's terminology resource is not readable }
  230.     errOSACorruptTerminology    = -2705;
  231.  
  232. { Signaled when the runtime stack overflows }
  233.     errOSAStackOverflow            = -2706;
  234.  
  235. { Signaled when a runtime internal data structure overflows }
  236.     errOSAInternalTableOverflow    = -2707;
  237.  
  238. {
  239.         Signaled when an intrinsic limitation is exceeded for the size of 
  240.           a value or data structure.
  241.     }
  242.     errOSADataBlockTooLarge        = -2708;
  243.  
  244.     errOSACantGetTerminology    = -2709;
  245.  
  246.     errOSACantCreate            = -2710;
  247.  
  248. {        Component-specific dynamic script errors:
  249.  
  250.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  251.     (Note that error codes from different scripting components in this range will
  252.     overlap.)
  253. }
  254. {        Static errors:
  255.  
  256.     These errors comprise what are commonly thought of as parse and compile-
  257.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  258.     of these may also occur at runtime.
  259. }
  260.  
  261. { Signaled when data was not the right type and coercion is not allowed }
  262.     errOSATypeError                = -1703;
  263.  
  264. { Signaled when a message was sent to an object that didn't handle it }
  265.     OSAMessageNotUnderstood        = -1708;
  266.  
  267. {
  268.         Signaled when a function to be returned doesn't exist.  (Probably only
  269.           useful in languages with first-class functions that distinguish between
  270.           functions and other values (two name spaces). This is different from
  271.           errOSAMessageNotUnderstood, which may be signaled when the method is
  272.           invoked.
  273.     }
  274.     OSAUndefinedHandler            = -1717;
  275.  
  276. { Signaled when a container can never have the requested object }
  277.     OSAIllegalAccess            = -1723;
  278.  
  279. { Signaled when index was out of range. Specialization of errOSACantAccess. }
  280.     OSAIllegalIndex                = -1719;
  281.  
  282. { Signaled when a range is screwy. Specialization of errOSACantAccess. }
  283.     OSAIllegalRange                = -1720;
  284.  
  285. {
  286.         Signaled when an object can never be set in a container.  Same as 
  287.           AERegistry error errAENotModifiable.
  288.     }
  289.     OSAIllegalAssign            = -10003;
  290.  
  291. {
  292.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  293.          "<this> can't go after <that>").
  294.     }
  295.     OSASyntaxError                = -2740;
  296.  
  297. {
  298.         Signaled when another form of syntax was expected. (e.g. "expected
  299.           a <type> but found <this>").
  300.     }
  301.     OSASyntaxTypeError            = -2741;
  302.  
  303. { Signaled when a name or number is too long to be parsed }
  304.     OSATokenTooLong                = -2742;
  305.  
  306. {
  307.         Signaled when a parameter is missing for a function invocation.  Note
  308.           that in some languages, this error may occur at runtime.
  309.     }
  310.     OSAMissingParameter            = -1701;
  311.  
  312. {
  313.         Signaled when function is called with the wrong number of parameters,
  314.           or a parameter pattern cannot be matched.
  315.     }
  316.     OSAParameterMismatch        = -1721;
  317.  
  318. {
  319.         Signaled when a formal parameter, local variable, or instance variable
  320.           is specified more than once.
  321.     }
  322.     OSADuplicateParameter        = -2750;
  323.  
  324. {
  325.         Signaled when a formal parameter, local variable, or instance variable
  326.           is specified more than once.
  327.     }
  328.     OSADuplicateProperty        = -2751;
  329.  
  330. {
  331.         Signaled when more than one handler is defined with the same name in 
  332.           a scope where the language doesn't allow it.
  333.     }
  334.     OSADuplicateHandler            = -2752;
  335.  
  336. { Signaled when a variable is accessed that has no value }
  337.     OSAUndefinedVariable        = -2753;
  338.  
  339. {
  340.         Signaled when a variable is declared inconsistently in the same scope,
  341.           such as both local and global.
  342.     }
  343.     OSAInconsistentDeclarations    = -2754;
  344.  
  345. {
  346.         Signaled when illegal control flow occurs in an application (no catcher
  347.           for throw, non-lexical loop exit, etc.).
  348.     }
  349.     OSAControlFlowError            = -2755;
  350.  
  351. {        Component-specific static script errors:
  352.  
  353.     The range -2760 thru -2779 is reserved for component-specific parsing and
  354.     compile-time errors. (Note that error codes from different scripting
  355.     components in this range will overlap.)
  356. }
  357. {        Dialect-specific script errors:
  358.  
  359.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  360.     scripting components that support dialects. (Note that error codes from
  361.     different scripting components in this range will overlap, as well as error
  362.     codes from different dialects in the same scripting component.)
  363. }
  364. {*************************************************************************
  365.     OSA Interface Descriptions
  366. **************************************************************************
  367.     The OSA Interface is broken down into a required interface, and several
  368.     optional interfaces to support additional functionality.  A given scripting
  369.     component may choose to support only some of the optional interfaces in
  370.     addition to the basic interface.  The OSA Component Flags may be used to 
  371.     query the Component Manager to find a scripting component with a particular
  372.     capability, or determine if a particular scripting component supports a 
  373.     particular capability.
  374. *************************************************************************}
  375. { OSA Component Flags: }
  376.     kOSASupportsCompiling        = $0002;
  377.     kOSASupportsGetSource        = $0004;
  378.     kOSASupportsAECoercion        = $0008;
  379.     kOSASupportsAESending        = $0010;
  380.     kOSASupportsRecording        = $0020;
  381.     kOSASupportsConvenience        = $0040;
  382.     kOSASupportsDialects        = $0080;
  383.     kOSASupportsEventHandling    = $0100;
  384.  
  385. { Component Selectors: }
  386.     kOSASelectLoad                = $0001;
  387.     kOSASelectStore                = $0002;
  388.     kOSASelectExecute            = $0003;
  389.     kOSASelectDisplay            = $0004;
  390.     kOSASelectScriptError        = $0005;
  391.     kOSASelectDispose            = $0006;
  392.     kOSASelectSetScriptInfo        = $0007;
  393.     kOSASelectGetScriptInfo        = $0008;
  394.     kOSASelectSetActiveProc        = $0009;
  395.     kOSASelectGetActiveProc        = $000A;
  396.  
  397. { Compiling: }
  398.     kOSASelectScriptingComponentName = $0102;
  399.     kOSASelectCompile            = $0103;
  400.     kOSASelectCopyID            = $0104;
  401.  
  402. { GetSource: }
  403.     kOSASelectGetSource            = $0201;
  404.  
  405. { AECoercion: }
  406.     kOSASelectCoerceFromDesc    = $0301;
  407.     kOSASelectCoerceToDesc        = $0302;
  408.  
  409. { AESending: }
  410.     kOSASelectSetSendProc        = $0401;
  411.     kOSASelectGetSendProc        = $0402;
  412.     kOSASelectSetCreateProc        = $0403;
  413.     kOSASelectGetCreateProc        = $0404;
  414.     kOSASelectSetDefaultTarget    = $0405;
  415.  
  416. { Recording: }
  417.     kOSASelectStartRecording    = $0501;
  418.     kOSASelectStopRecording        = $0502;
  419.  
  420. { Convenience: }
  421.     kOSASelectLoadExecute        = $0601;
  422.     kOSASelectCompileExecute    = $0602;
  423.     kOSASelectDoScript            = $0603;
  424.  
  425. { Dialects: }
  426.     kOSASelectSetCurrentDialect    = $0701;
  427.     kOSASelectGetCurrentDialect    = $0702;
  428.     kOSASelectAvailableDialects    = $0703;
  429.     kOSASelectGetDialectInfo    = $0704;
  430.     kOSASelectAvailableDialectCodeList = $0705;
  431.  
  432. { Event Handling: }
  433.     kOSASelectSetResumeDispatchProc = $0801;
  434.     kOSASelectGetResumeDispatchProc = $0802;
  435.     kOSASelectExecuteEvent        = $0803;
  436.     kOSASelectDoEvent            = $0804;
  437.     kOSASelectMakeContext        = $0805;
  438.  
  439.  
  440. { scripting component specific selectors are added beginning with this value  }
  441.     kOSASelectComponentSpecificStart = $1001;
  442.  
  443.  
  444. {        Mode Flags:
  445.  
  446.     Warning: These should not conflict with the AESend mode flags in
  447.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  448. }
  449.  
  450. {
  451.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  452.           instruct the scripting component to not retain the "source" of an
  453.           expression.  This will cause the OSAGetSource call to return the error
  454.           errOSASourceNotAvailable if used.  However, some scripting components
  455.           may not retain the source anyway.  This is mainly used when either space
  456.           efficiency is desired, or a script is to be "locked" so that its
  457.           implementation may not be viewed.
  458.     }
  459.     kOSAModePreventGetSource    = $00000001;
  460.  
  461. {
  462.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  463.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  464.           indicate whether or not the script may interact with the user, switch
  465.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  466.           corresponding AESend mode supplied.
  467.     }
  468.     kOSAModeNeverInteract        = $00000010;
  469.     kOSAModeCanInteract            = $00000020;
  470.     kOSAModeAlwaysInteract        = $00000030;
  471.     kOSAModeDontReconnect        = $00000080;
  472.  
  473. {
  474.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  475.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  476.           indicate whether or not AppleEvents should be sent with the
  477.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  478.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  479.           provide a more convenient default, i.e. not supplying any mode
  480.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  481.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  482.           without kAECanSwitchLayer.
  483.     }
  484.     kOSAModeCantSwitchLayer        = $00000040;
  485.  
  486. {
  487.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  488.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  489.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  490.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  491.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  492.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  493.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  494.           cause AESend to be called without kAEDontRecord.
  495.     }
  496.     kOSAModeDoRecord            = $00001000;
  497.  
  498. {
  499.         This is a mode flag for OSACompile that indicates that a context should
  500.           be created as the result of compilation. All handler definitions are
  501.           inserted into the new context, and variables are initialized by
  502.           evaluating their initial values in a null context (i.e. they must be
  503.           constant expressions).
  504.     }
  505.     kOSAModeCompileIntoContext    = $00000002;
  506.  
  507. {
  508.         This is a mode flag for OSACompile that indicates that the previous
  509.           script ID (input to OSACompile) should be augmented with any new
  510.           definitions in the sourceData rather than replaced with a new script.
  511.           This means that the previous script ID must designate a context.
  512.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  513.           to be implicitly used, causing any new definitions to be initialized
  514.           in a null context.
  515.     }
  516.     kOSAModeAugmentContext        = $00000004;
  517.  
  518. {
  519.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  520.           that output only need be human-readable, not re-compilable by OSACompile.
  521.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  522.           off of string values, long lists may have elipses, etc.
  523.     }
  524.     kOSAModeDisplayForHumans    = $00000008;
  525.  
  526. {
  527.         This mode flag may be passed to OSAStore in the case where the scriptID
  528.           is a context.  This causes the context to be saved, but not the context's
  529.           parent context.  When the stored context is loaded back in, the parent
  530.           will be kOSANullScript.
  531.     }
  532.     kOSAModeDontStoreParent        = $00010000;
  533.  
  534. {
  535.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  536.           be dispatched to the direct object of the event. The direct object (or
  537.           subject attribute if the direct object is a non-object specifier) will
  538.           be resolved, and the resulting script object will be the recipient of
  539.           the message. The context argument to OSAExecuteEvent will serve as the
  540.           root of the lookup/resolution process.
  541.     }
  542.     kOSAModeDispatchToDirectObject = $00020000;
  543.  
  544. {
  545.         This mode flag may be passed to OSAExecuteEvent to indicate that
  546.           components do not have to get the data of object specifier arguments.
  547.     }
  548.     kOSAModeDontGetDataForArguments = $00040000;
  549.  
  550. {*************************************************************************
  551.     OSA Basic Scripting Interface
  552. **************************************************************************
  553.     Scripting components must at least support the Basic Scripting interface.
  554. *************************************************************************}
  555. {        Loading and Storing Scripts:
  556.  
  557.     These routines allow scripts to be loaded and stored in their internal
  558.     (possibly compiled, non-text) representation.
  559. }
  560.  
  561. { Resource type for scripts }
  562.     kOSAScriptResourceType        = 'scpt';
  563.  
  564. {
  565.         Default type given to OSAStore which creates "generic" loadable script
  566.           data descriptors.
  567.     }
  568.     typeOSAGenericStorage        = 'scpt';
  569.  
  570. FUNCTION OSALoad(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  571.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  572.     INLINE $2F3C, $000C, $0001, $7000, $A82A;
  573.     {$ENDC}
  574. {
  575.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  576.     
  577.         Errors:
  578.             badComponentInstance        invalid scripting component instance
  579.             errOSASystemError
  580.             errOSABadStorageType:        scriptData not for this scripting component
  581.             errOSACorruptData:            data seems to be corrupt
  582.             errOSADataFormatObsolete    script data format is no longer supported
  583.             errOSADataFormatTooNew        script data format is from a newer version
  584.         
  585.         ModeFlags:
  586.             kOSAModePreventGetSource
  587.     }
  588. FUNCTION OSAStore(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingScriptData: AEDesc): OSAError;
  589.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  590.     INLINE $2F3C, $0010, $0002, $7000, $A82A;
  591.     {$ENDC}
  592. {
  593.         OSAComponentFunctionInline(kOSASelectStore, 16);
  594.     
  595.         Errors:
  596.             badComponentInstance    invalid scripting component instance
  597.             errOSASystemError
  598.             errOSAInvalidID
  599.             errOSABadStorageType:    desiredType not for this scripting component
  600.         
  601.         ModeFlags:
  602.             kOSAModePreventGetSource
  603.             kOSAModeDontStoreParent
  604.     }
  605. { Executing Scripts: }
  606. FUNCTION OSAExecute(scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  607.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  608.     INLINE $2F3C, $0010, $0003, $7000, $A82A;
  609.     {$ENDC}
  610. {
  611.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  612.         This call runs a script.  The contextID represents the environment
  613.         with which global variables in the script are resolved.  The constant
  614.         kOSANullScript may be used for the contextID if the application wishes
  615.         to not deal with context directly (a default one is associated with each
  616.         scripting component instance).  The resultingScriptValueID is the 
  617.         result of evaluation, and contains a value which may be displayed using
  618.         the OSAGetSource call.  The modeFlags convey scripting component
  619.         specific information.
  620.     
  621.         Errors:
  622.             badComponentInstance    invalid scripting component instance
  623.             errOSASystemError
  624.             errOSAInvalidID
  625.             errOSAScriptError:        the executing script got an error
  626.     
  627.         ModeFlags:
  628.             kOSAModeNeverInteract
  629.             kOSAModeCanInteract
  630.             kOSAModeAlwaysInteract
  631.             kOSAModeCantSwitchLayer
  632.             kOSAModeDontReconnect
  633.             kOSAModeDoRecord
  634.     }
  635. { Displaying results: }
  636. FUNCTION OSADisplay(scriptingComponent: ComponentInstance; scriptValueID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  637.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  638.     INLINE $2F3C, $0010, $0004, $7000, $A82A;
  639.     {$ENDC}
  640. {
  641.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  642.         This call is used to convert results (script value IDs) into displayable
  643.         text. The desiredType should be at least typeChar, and modeFlags are
  644.         scripting system specific flags to control the formatting of the
  645.         resulting text. This call differs from OSAGetSource in that (1) it
  646.         always produces at least typeChar, (2) is only works on script values,
  647.         (3) it may display it's output in non-compilable form (e.g. without
  648.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  649.         (4) it is required by the basic scripting interface.
  650.     
  651.         Errors:
  652.             badComponentInstance    invalid scripting component instance
  653.             errOSASystemError
  654.             errOSAInvalidID
  655.             errAECoercionFail:        desiredType not supported by scripting component
  656.     
  657.         ModeFlags:
  658.             kOSAModeDisplayForHumans
  659.     }
  660. { Getting Error Information: }
  661. FUNCTION OSAScriptError(scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; VAR resultingErrorDescription: AEDesc): OSAError;
  662.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  663.     INLINE $2F3C, $000C, $0005, $7000, $A82A;
  664.     {$ENDC}
  665. {
  666.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  667.         Whenever script execution returns errOSAExecutionError, this routine
  668.         may be used to get information about that error.  The selector describes
  669.         the type of information desired about the error (various selectors are
  670.         listed below).  The desiredType indicates the data type of the result
  671.         desired for that selector.
  672.     
  673.         Errors:
  674.             badComponentInstance    invalid scripting component instance
  675.             errOSASystemError
  676.             errOSABadSelector:        selector not supported by scripting component
  677.             errAECoercionFail:        desiredType not supported by scripting component
  678.     }
  679. { OSAScriptError selectors: }
  680. {
  681.         This selector is used to determine the error number of a script error.
  682.         These error numbers may be either system error numbers, or error numbers
  683.         that are scripting component specific.
  684.         Required desiredTypes:    
  685.               typeShortInteger
  686.     }
  687.  
  688. CONST
  689.     kOSAErrorNumber                = 'errn';
  690.  
  691. {
  692.         This selector is used to determine the full error message associated
  693.         with the error number.  It should include the name of the application
  694.         which caused the error, as well as the specific error that occurred.
  695.         This selector is sufficient for simple error reporting (but see
  696.         kOSAErrorBriefMessage, below).
  697.         Required desiredTypes:
  698.             typeChar                    error message string
  699.     }
  700.     kOSAErrorMessage            = 'errs';
  701.  
  702. {
  703.         This selector is used to determine a brief error message associated with
  704.         the error number.  This message and should not mention the name of the
  705.         application which caused the error, any partial results or offending
  706.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  707.         kOSAErrorOffendingObject, below).
  708.         Required desiredTypes:
  709.               typeChar                    brief error message string
  710.     }
  711. {  0x65727262  }
  712.     kOSAErrorBriefMessage        = 'errb';
  713.  
  714. {
  715.         This selector is used to determine which application actually got the
  716.         error (if it was the result of an AESend), or the current application
  717.         if ....
  718.         Required desiredTypes:
  719.               typeProcessSerialNumber        PSN of the errant application
  720.               typeChar                    name of the errant application
  721.     }
  722. {  0x65726170  }
  723.     kOSAErrorApp                = 'erap';
  724.  
  725. {
  726.         This selector is used to determine any partial result returned by an 
  727.         operation. If an AESend call failed, but a partial result was returned,
  728.         then the partial result may be returned as an AEDesc.
  729.         Required desiredTypes:
  730.               typeBest                    AEDesc of any partial result
  731.     }
  732. {  0x70746c72   }
  733.     kOSAErrorPartialResult        = 'ptlr';
  734.  
  735. {
  736.         This selector is used to determine any object which caused the error
  737.         that may have been indicated by an application.  The result is an 
  738.         AEDesc.
  739.         Required desiredTypes:
  740.               typeBest                    AEDesc of any offending object
  741.     }
  742. {  0x65726f62   }
  743.     kOSAErrorOffendingObject    = 'erob';
  744.  
  745. {
  746.         This selector is used to determine the type expected by a coercion 
  747.         operation if a type error occurred.
  748.     }
  749. {  0x65727274   }
  750.     kOSAErrorExpectedType        = 'errt';
  751.  
  752. {
  753.         This selector is used to determine the source text range (start and 
  754.         end positions) of where the error occurred.
  755.         Required desiredTypes:
  756.               typeOSAErrorRange
  757.     }
  758. {  0x65726e67  }
  759.     kOSAErrorRange                = 'erng';
  760.  
  761. {
  762.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  763.         of type short.
  764.     }
  765. {  0x65726e67   }
  766.     typeOSAErrorRange            = 'erng';
  767.  
  768. { Field of a typeOSAErrorRange record of typeShortInteger }
  769. {  0x73726373    }
  770.     keyOSASourceStart            = 'srcs';
  771.  
  772. { Field of a typeOSAErrorRange record of typeShortInteger }
  773. {  0x73726365   }
  774.     keyOSASourceEnd                = 'srce';
  775.  
  776. { Disposing Script IDs: }
  777. FUNCTION OSADispose(scriptingComponent: ComponentInstance; scriptID: OSAID): OSAError;
  778.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  779.     INLINE $2F3C, $0004, $0006, $7000, $A82A;
  780.     {$ENDC}
  781. {
  782.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  783.         Disposes a script or context.
  784.     
  785.         Errors:
  786.             badComponentInstance    invalid scripting component instance
  787.             errOSASystemError
  788.             errOSAInvalidID
  789.     }
  790. { Getting and Setting Script Information: }
  791. FUNCTION OSASetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; value: LONGINT): OSAError;
  792.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  793.     INLINE $2F3C, $000C, $0007, $7000, $A82A;
  794.     {$ENDC}
  795. {
  796.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  797.     
  798.         Errors:
  799.             badComponentInstance    invalid scripting component instance
  800.             errOSASystemError
  801.             errOSAInvalidID
  802.             errOSABadSelector:        selector not supported by scripting component
  803.                                     or selector not for this scriptID
  804.     }
  805. FUNCTION OSAGetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; VAR result: LONGINT): OSAError;
  806.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  807.     INLINE $2F3C, $000C, $0008, $7000, $A82A;
  808.     {$ENDC}
  809. {
  810.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  811.     
  812.         Errors:
  813.             badComponentInstance    invalid scripting component instance
  814.             errOSASystemError
  815.             errOSAInvalidID
  816.             errOSABadSelector:        selector not supported by scripting component
  817.                                     or selector not for this scriptID
  818.     }
  819. { Manipulating the ActiveProc:
  820.  
  821.     Scripting systems will supply default values for these procedures if they
  822.     are not set by the client:
  823. }
  824.  
  825. TYPE
  826. {$IFC TYPED_FUNCTION_POINTERS}
  827.     OSAActiveProcPtr = FUNCTION(refCon: LONGINT): OSErr;
  828. {$ELSEC}
  829.     OSAActiveProcPtr = ProcPtr;
  830. {$ENDC}
  831.  
  832.     OSAActiveUPP = UniversalProcPtr;
  833.  
  834. CONST
  835.     uppOSAActiveProcInfo = $000000E0;
  836.  
  837. FUNCTION NewOSAActiveProc(userRoutine: OSAActiveProcPtr): OSAActiveUPP;
  838.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  839.     INLINE $2E9F;
  840.     {$ENDC}
  841.  
  842. FUNCTION CallOSAActiveProc(refCon: LONGINT; userRoutine: OSAActiveUPP): OSErr;
  843.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  844.     INLINE $205F, $4E90;
  845.     {$ENDC}
  846. FUNCTION OSASetActiveProc(scriptingComponent: ComponentInstance; activeProc: OSAActiveUPP; refCon: LONGINT): OSAError;
  847.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  848.     INLINE $2F3C, $0008, $0009, $7000, $A82A;
  849.     {$ENDC}
  850. {
  851.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  852.         If activeProc is nil, the default activeProc is used.
  853.     
  854.         Errors:
  855.             badComponentInstance    invalid scripting component instance
  856.             errOSASystemError
  857.     }
  858. FUNCTION OSAGetActiveProc(scriptingComponent: ComponentInstance; VAR activeProc: OSAActiveUPP; VAR refCon: LONGINT): OSAError;
  859.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  860.     INLINE $2F3C, $0008, $000A, $7000, $A82A;
  861.     {$ENDC}
  862. {
  863.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  864.     
  865.         Errors:
  866.             badComponentInstance    invalid scripting component instance
  867.             errOSASystemError
  868.     }
  869. {*************************************************************************
  870.     OSA Optional Compiling Interface
  871. **************************************************************************
  872.     Scripting components that support the Compiling interface have the 
  873.     kOSASupportsCompiling bit set in it's ComponentDescription.
  874. *************************************************************************}
  875. FUNCTION OSAScriptingComponentName(scriptingComponent: ComponentInstance; VAR resultingScriptingComponentName: AEDesc): OSAError;
  876.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  877.     INLINE $2F3C, $0004, $0102, $7000, $A82A;
  878.     {$ENDC}
  879. {
  880.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  881.         Given a scripting component, this routine returns the name of that
  882.         scripting component in a type that is coercable to text (typeChar).
  883.         The generic scripting component returns the name of the default
  884.         scripting component.  This name should be sufficient to convey to the
  885.         user the kind of script (syntax) he is expected to write.
  886.     
  887.         Errors:
  888.             badComponentInstance    invalid scripting component instance
  889.             errOSASystemError
  890.     }
  891. FUNCTION OSACompile(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; modeFlags: LONGINT; VAR previousAndResultingScriptID: OSAID): OSAError;
  892.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  893.     INLINE $2F3C, $000C, $0103, $7000, $A82A;
  894.     {$ENDC}
  895. {
  896.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  897.         Coerces input desc (possibly text) into a script's internal format.
  898.         Once compiled, the script is ready to run.  The modeFlags convey
  899.         scripting component specific information.  The previous script ID
  900.         (result parameter) is made to refer to the newly compiled script,
  901.         unless it was originally kOSANullScript.  In this case a new script
  902.         ID is created and used.
  903.     
  904.         Errors:
  905.             badComponentInstance    invalid scripting component instance
  906.             errOSASystemError
  907.             errAECoercionFail:        sourceData is not compilable
  908.             errOSAScriptError:        sourceData was a bad script (syntax error)
  909.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  910.                                     valid on input
  911.     
  912.         ModeFlags:
  913.             kOSAModePreventGetSource
  914.             kOSAModeCompileIntoContext
  915.             kOSAModeAugmentContext
  916.             kOSAModeNeverInteract
  917.             kOSAModeCanInteract
  918.             kOSAModeAlwaysInteract
  919.             kOSAModeCantSwitchLayer
  920.             kOSAModeDontReconnect
  921.             kOSAModeDoRecord
  922.     }
  923. FUNCTION OSACopyID(scriptingComponent: ComponentInstance; fromID: OSAID; VAR toID: OSAID): OSAError;
  924.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  925.     INLINE $2F3C, $0008, $0104, $7000, $A82A;
  926.     {$ENDC}
  927. {
  928.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  929.         If toID is a reference to kOSANullScript then it is updated to have a
  930.         new scriptID value.  This call can be used to perform undo or revert
  931.         operations on scripts. 
  932.     
  933.         Errors:
  934.             badComponentInstance    invalid scripting component instance
  935.             errOSASystemError
  936.             errOSAInvalidID
  937.     }
  938. {*************************************************************************
  939.     OSA Optional GetSource Interface
  940. **************************************************************************
  941.     Scripting components that support the GetSource interface have the 
  942.     kOSASupportsGetSource bit set in it's ComponentDescription.
  943. *************************************************************************}
  944. FUNCTION OSAGetSource(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; VAR resultingSourceData: AEDesc): OSAError;
  945.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  946.     INLINE $2F3C, $000C, $0201, $7000, $A82A;
  947.     {$ENDC}
  948. {
  949.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  950.         This routine causes a compiled script to be output in a form (possibly
  951.         text) such that it is suitable to be passed back to OSACompile.
  952.  
  953.         Errors:
  954.             badComponentInstance    invalid scripting component instance
  955.             errOSASystemError
  956.             errOSAInvalidID
  957.             errOSASourceNotAvailable    can't get source for this scriptID
  958.     }
  959. {*************************************************************************
  960.     OSA Optional AECoercion Interface
  961. **************************************************************************
  962.     Scripting components that support the AECoercion interface have the 
  963.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  964. *************************************************************************}
  965. FUNCTION OSACoerceFromDesc(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  966.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  967.     INLINE $2F3C, $000C, $0301, $7000, $A82A;
  968.     {$ENDC}
  969. {
  970.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  971.         This routine causes script data to be coerced into a script value.
  972.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  973.         compiled script ID (mode flags for OSACompile may be used in this case).
  974.         Other scriptData descriptors create script value IDs.
  975.     
  976.         Errors:
  977.             badComponentInstance    invalid scripting component instance
  978.             errOSASystemError
  979.     
  980.         ModeFlags:
  981.             kOSAModePreventGetSource
  982.             kOSAModeCompileIntoContext
  983.             kOSAModeNeverInteract
  984.             kOSAModeCanInteract
  985.             kOSAModeAlwaysInteract
  986.             kOSAModeCantSwitchLayer
  987.             kOSAModeDontReconnect
  988.             kOSAModeDoRecord
  989.     }
  990. FUNCTION OSACoerceToDesc(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR result: AEDesc): OSAError;
  991.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  992.     INLINE $2F3C, $0010, $0302, $7000, $A82A;
  993.     {$ENDC}
  994. {
  995.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  996.         This routine causes a script value to be coerced into any desired form.
  997.         If the scriptID denotes a compiled script, then it may be coerced to 
  998.         typeAppleEvent.
  999.     
  1000.         Errors:
  1001.             badComponentInstance    invalid scripting component instance
  1002.             errOSASystemError
  1003.             errOSAInvalidID
  1004.     }
  1005. {*************************************************************************
  1006.     OSA Optional AESending Interface
  1007. **************************************************************************
  1008.     Scripting components that support the AESending interface have the 
  1009.     kOSASupportsAESending bit set in it's ComponentDescription.
  1010. *************************************************************************}
  1011. {
  1012.     Scripting systems will supply default values for these procedures if they
  1013.     are not set by the client:
  1014. }
  1015. FUNCTION OSASetSendProc(scriptingComponent: ComponentInstance; sendProc: OSASendUPP; refCon: LONGINT): OSAError;
  1016.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1017.     INLINE $2F3C, $0008, $0401, $7000, $A82A;
  1018.     {$ENDC}
  1019. {
  1020.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1021.         If sendProc is nil, the default sendProc is used.
  1022.     
  1023.         Errors:
  1024.             badComponentInstance    invalid scripting component instance
  1025.             errOSASystemError
  1026.     }
  1027. FUNCTION OSAGetSendProc(scriptingComponent: ComponentInstance; VAR sendProc: OSASendUPP; VAR refCon: LONGINT): OSAError;
  1028.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1029.     INLINE $2F3C, $0008, $0402, $7000, $A82A;
  1030.     {$ENDC}
  1031. {
  1032.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1033.     
  1034.         Errors:
  1035.             badComponentInstance    invalid scripting component instance
  1036.             errOSASystemError
  1037.     }
  1038. FUNCTION OSASetCreateProc(scriptingComponent: ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: LONGINT): OSAError;
  1039.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1040.     INLINE $2F3C, $0008, $0403, $7000, $A82A;
  1041.     {$ENDC}
  1042. {
  1043.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1044.         If createProc is nil, the default createProc is used.
  1045.     
  1046.         Errors:
  1047.             badComponentInstance    invalid scripting component instance
  1048.             errOSASystemError
  1049.     }
  1050. FUNCTION OSAGetCreateProc(scriptingComponent: ComponentInstance; VAR createProc: OSACreateAppleEventUPP; VAR refCon: LONGINT): OSAError;
  1051.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1052.     INLINE $2F3C, $0008, $0404, $7000, $A82A;
  1053.     {$ENDC}
  1054. {
  1055.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1056.     
  1057.         Errors:
  1058.             badComponentInstance    invalid scripting component instance
  1059.             errOSASystemError
  1060.     }
  1061. FUNCTION OSASetDefaultTarget(scriptingComponent: ComponentInstance; {CONST}VAR target: AEAddressDesc): OSAError;
  1062.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1063.     INLINE $2F3C, $0004, $0405, $7000, $A82A;
  1064.     {$ENDC}
  1065. {
  1066.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1067.         This routine sets the default target application for AE sending.
  1068.         It also establishes the default target from which terminologies come.
  1069.         It is effectively like having an AppleScript "tell" statement around
  1070.         the entire program.  If this routine is not called, or if the target 
  1071.         is a null AEDesc, then the current application is the default target.
  1072.     
  1073.         Errors:
  1074.             badComponentInstance    invalid scripting component instance
  1075.             errOSASystemError
  1076.     }
  1077. {*************************************************************************
  1078.     OSA Optional Recording Interface
  1079. **************************************************************************
  1080.     Scripting components that support the Recording interface have the 
  1081.     kOSASupportsRecording bit set in it's ComponentDescription.
  1082. *************************************************************************}
  1083. FUNCTION OSAStartRecording(scriptingComponent: ComponentInstance; VAR compiledScriptToModifyID: OSAID): OSAError;
  1084.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1085.     INLINE $2F3C, $0004, $0501, $7000, $A82A;
  1086.     {$ENDC}
  1087. {
  1088.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1089.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1090.         new script ID is created and returned.  If the current application has
  1091.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1092.         are sent to the application containing the text of each AppleEvent 
  1093.         recorded.
  1094.     
  1095.         Errors:
  1096.             badComponentInstance    invalid scripting component instance
  1097.             errOSASystemError
  1098.             errOSAInvalidID
  1099.             errOSARecordingIsAlreadyOn
  1100.     }
  1101. FUNCTION OSAStopRecording(scriptingComponent: ComponentInstance; compiledScriptID: OSAID): OSAError;
  1102.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1103.     INLINE $2F3C, $0004, $0502, $7000, $A82A;
  1104.     {$ENDC}
  1105. {
  1106.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1107.         If compiledScriptID is not being recorded into or recording is not
  1108.         currently on, no error is returned.
  1109.     
  1110.         Errors:
  1111.             badComponentInstance    invalid scripting component instance
  1112.             errOSASystemError
  1113.             errOSAInvalidID
  1114.     }
  1115. {*************************************************************************
  1116.     OSA Optional Convenience Interface
  1117. **************************************************************************
  1118.     Scripting components that support the Convenience interface have the 
  1119.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1120. *************************************************************************}
  1121. FUNCTION OSALoadExecute(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1122.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1123.     INLINE $2F3C, $0010, $0601, $7000, $A82A;
  1124.     {$ENDC}
  1125. {
  1126.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1127.         This routine is effectively equivalent to calling OSALoad followed by
  1128.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1129.         resulting value ID is retained.
  1130.     
  1131.         Errors:
  1132.             badComponentInstance        invalid scripting component instance
  1133.             errOSASystemError
  1134.             errOSABadStorageType:        scriptData not for this scripting component
  1135.             errOSACorruptData:            data seems to be corrupt
  1136.             errOSADataFormatObsolete    script data format is no longer supported
  1137.             errOSADataFormatTooNew        script data format is from a newer version
  1138.             errOSAInvalidID
  1139.             errOSAScriptError:            the executing script got an error
  1140.     
  1141.         ModeFlags:
  1142.             kOSAModeNeverInteract
  1143.             kOSAModeCanInteract
  1144.             kOSAModeAlwaysInteract
  1145.             kOSAModeCantSwitchLayer
  1146.             kOSAModeDontReconnect
  1147.             kOSAModeDoRecord
  1148.     }
  1149. FUNCTION OSACompileExecute(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1150.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1151.     INLINE $2F3C, $0010, $0602, $7000, $A82A;
  1152.     {$ENDC}
  1153. {
  1154.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1155.         This routine is effectively equivalent to calling OSACompile followed by
  1156.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1157.         resulting value ID is retained.
  1158.     
  1159.         Errors:
  1160.             badComponentInstance    invalid scripting component instance
  1161.             errOSASystemError
  1162.             errAECoercionFail:        sourceData is not compilable
  1163.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1164.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1165.                                     valid on input
  1166.             errOSAScriptError:        the executing script got an error
  1167.     
  1168.         ModeFlags:
  1169.             kOSAModeNeverInteract
  1170.             kOSAModeCanInteract
  1171.             kOSAModeAlwaysInteract
  1172.             kOSAModeCantSwitchLayer
  1173.             kOSAModeDontReconnect
  1174.             kOSAModeDoRecord
  1175.     }
  1176. FUNCTION OSADoScript(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  1177.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1178.     INLINE $2F3C, $0014, $0603, $7000, $A82A;
  1179.     {$ENDC}
  1180. {
  1181.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1182.         This routine is effectively equivalent to calling OSACompile followed by
  1183.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1184.         and the resulting value are is disposed.  Only the resultingText
  1185.         descriptor is retained.  If a script error occur during processing, the 
  1186.         resultingText gets the error message of the error, and errOSAScriptError
  1187.         is returned.  OSAScriptError may still be used to extract more 
  1188.         information about the particular error.
  1189.     
  1190.         Errors:
  1191.             badComponentInstance    invalid scripting component instance
  1192.             errOSASystemError
  1193.             errAECoercionFail:        sourceData is not compilable or 
  1194.                                     desiredType not supported by scripting component
  1195.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1196.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1197.                                     valid on input
  1198.             errOSAScriptError:        the executing script got an error
  1199.     
  1200.         ModeFlags:
  1201.             kOSAModeNeverInteract
  1202.             kOSAModeCanInteract
  1203.             kOSAModeAlwaysInteract
  1204.             kOSAModeCantSwitchLayer
  1205.             kOSAModeDontReconnect
  1206.             kOSAModeDoRecord
  1207.             kOSAModeDisplayForHumans
  1208.     }
  1209. {*************************************************************************
  1210.     OSA Optional Dialects Interface
  1211. **************************************************************************
  1212.     Scripting components that support the Dialects interface have the 
  1213.     kOSASupportsDialects bit set in it's ComponentDescription.
  1214. *************************************************************************}
  1215. {
  1216.     These calls allows an scripting component that supports different dialects
  1217.     to dynamically switch between those dialects.  Although this interface is
  1218.     specified, the particular dialect codes are scripting component dependent.
  1219. }
  1220. FUNCTION OSASetCurrentDialect(scriptingComponent: ComponentInstance; dialectCode: INTEGER): OSAError;
  1221.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1222.     INLINE $2F3C, $0002, $0701, $7000, $A82A;
  1223.     {$ENDC}
  1224. {
  1225.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1226.     
  1227.         Errors:
  1228.             badComponentInstance    invalid scripting component instance
  1229.             errOSASystemError
  1230.             errOSANoSuchDialect:    invalid dialectCode
  1231.     }
  1232. FUNCTION OSAGetCurrentDialect(scriptingComponent: ComponentInstance; VAR resultingDialectCode: INTEGER): OSAError;
  1233.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1234.     INLINE $2F3C, $0004, $0702, $7000, $A82A;
  1235.     {$ENDC}
  1236. {
  1237.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1238.     
  1239.         Errors:
  1240.             badComponentInstance    invalid scripting component instance
  1241.             errOSASystemError
  1242.     }
  1243. FUNCTION OSAAvailableDialects(scriptingComponent: ComponentInstance; VAR resultingDialectInfoList: AEDesc): OSAError;
  1244.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1245.     INLINE $2F3C, $0004, $0703, $7000, $A82A;
  1246.     {$ENDC}
  1247. {
  1248.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1249.         This call return an AEList containing information about each of the
  1250.         currently available dialects of a scripting component.  Each item
  1251.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1252.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1253.         keyOSADialectScriptCode.
  1254.     
  1255.         Errors:
  1256.             badComponentInstance    invalid scripting component instance
  1257.             errOSASystemError
  1258.     }
  1259. FUNCTION OSAGetDialectInfo(scriptingComponent: ComponentInstance; dialectCode: INTEGER; selector: OSType; VAR resultingDialectInfo: AEDesc): OSAError;
  1260.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1261.     INLINE $2F3C, $000A, $0704, $7000, $A82A;
  1262.     {$ENDC}
  1263. {
  1264.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1265.         This call gives information about the specified dialect of a scripting
  1266.         component. It returns an AEDesc whose type depends on the selector 
  1267.         specified. Available selectors are the same as the field keys for a
  1268.         dialect info record. The type of AEDesc returned is the same as the 
  1269.         type of the field that has same key as the selector.
  1270.     
  1271.         Errors:
  1272.             badComponentInstance    invalid scripting component instance
  1273.             errOSASystemError
  1274.              errOSABadSelector
  1275.             errOSANoSuchDialect:    invalid dialectCode
  1276.     }
  1277. FUNCTION OSAAvailableDialectCodeList(scriptingComponent: ComponentInstance; VAR resultingDialectCodeList: AEDesc): OSAError;
  1278.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1279.     INLINE $2F3C, $0004, $0705, $7000, $A82A;
  1280.     {$ENDC}
  1281. {
  1282.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1283.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1284.         and  OSAGetDialectInfo to get information on dialects.
  1285.         This call return an AEList containing dialect code for each of the
  1286.         currently available dialects of a scripting component. Each dialect
  1287.         code is a short integer of type typeShortInteger.
  1288.     
  1289.         Errors:
  1290.             badComponentInstance    invalid scripting component instance
  1291.             errOSASystemError
  1292.  
  1293.         Type of a dialect info record containing at least keyOSADialectName
  1294.         and keyOSADialectCode fields.
  1295.  
  1296.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1297.  
  1298.         Field of a typeOSADialectInfo record of typeChar.
  1299.         Field of a typeOSADialectInfo record of typeShortInteger.
  1300.         Field of a typeOSADialectInfo record of typeShortInteger.
  1301.         Field of a typeOSADialectInfo record of typeShortInteger.
  1302.     }
  1303. {*************************************************************************
  1304.     OSA Optional Event Handling Interface
  1305. **************************************************************************
  1306.     Scripting components that support the Event Handling interface have the 
  1307.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1308. *************************************************************************}
  1309. FUNCTION OSASetResumeDispatchProc(scriptingComponent: ComponentInstance; resumeDispatchProc: AEEventHandlerUPP; refCon: LONGINT): OSAError;
  1310.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1311.     INLINE $2F3C, $0008, $0801, $7000, $A82A;
  1312.     {$ENDC}
  1313. {
  1314.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1315.         This function is used to set the ResumeDispatchProc that will be used
  1316.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1317.         found in the context, or the context event hander "continues" control
  1318.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1319.         may also be passed to this routine indicating that the handler registered
  1320.         in the application with AEInstallEventHandler should be used, or no
  1321.         dispatch should occur, respectively.
  1322.     
  1323.         Errors:
  1324.             badComponentInstance    invalid scripting component instance
  1325.             errOSASystemError
  1326.     }
  1327.  
  1328. CONST
  1329.     kOSAUseStandardDispatch        = $FFFFFFFF;
  1330.  
  1331. {
  1332.         Special ResumeDispatchProc constant which may be passed to 
  1333.         OSASetResumeDispatchProc indicating that the handler registered
  1334.         in the application with AEInstallEventHandler should be used.
  1335.         
  1336.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1337.                 doesn't allow pointer types to be assigned to an enum.  All
  1338.                 constants must be assigned as enums to translate properly to
  1339.                 Pascal.
  1340.     }
  1341.     kOSANoDispatch                = 0;
  1342.  
  1343. {
  1344.         Special ResumeDispatchProc constant which may be passed to 
  1345.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1346.         
  1347.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1348.                 doesn't allow pointer types to be assigned to an enum.  All
  1349.                 constants must be assigned as enums to translate properly to
  1350.                 Pascal.
  1351.     }
  1352.     kOSADontUsePhac                = $0001;
  1353.  
  1354. {
  1355.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1356.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1357.         This causes the standard dispatch to be performed, except the phac
  1358.         handler is not called.  This is useful during tinkerability, when
  1359.         the phac handler is used to lookup a context associated with an event's 
  1360.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1361.         bypass the phac handler would result in an infinite loop.
  1362.     }
  1363. FUNCTION OSAGetResumeDispatchProc(scriptingComponent: ComponentInstance; VAR resumeDispatchProc: AEEventHandlerUPP; VAR refCon: LONGINT): OSAError;
  1364.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1365.     INLINE $2F3C, $0008, $0802, $7000, $A82A;
  1366.     {$ENDC}
  1367. {
  1368.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1369.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1370.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1371.     
  1372.         Errors:
  1373.             badComponentInstance    invalid scripting component instance
  1374.             errOSASystemError
  1375.     }
  1376. FUNCTION OSAExecuteEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1377.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1378.     INLINE $2F3C, $0010, $0803, $7000, $A82A;
  1379.     {$ENDC}
  1380. {
  1381.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1382.         This call is similar to OSAExecute except the initial command to
  1383.         execute comes in the form of an AppleEvent.  If the contextID
  1384.         defines any event handlers for that event, they are used to process
  1385.         the event.  If no event handler can be found in the context
  1386.         errAEEventNotHandled is returned.  If an event handler is found and
  1387.         the hander "continues" control onward, the ResumeDispatchProc
  1388.         (registered with OSASetResumeDispatchProc, above) is called given the
  1389.         AppleEvent.  The result is returned as a scriptValueID.
  1390.     
  1391.         Errors:
  1392.             badComponentInstance    invalid scripting component instance
  1393.             errOSASystemError
  1394.             errOSAInvalidID
  1395.             errOSAScriptError:        the executing script got an error
  1396.             errAEEventNotHandled:    no handler for event in contextID
  1397.     
  1398.         ModeFlags:
  1399.             kOSAModeNeverInteract
  1400.             kOSAModeCanInteract
  1401.             kOSAModeAlwaysInteract
  1402.             kOSAModeCantSwitchLayer
  1403.             kOSAModeDontReconnect
  1404.             kOSAModeDoRecord
  1405.     }
  1406. FUNCTION OSADoEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR reply: AppleEvent): OSAError;
  1407.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1408.     INLINE $2F3C, $0010, $0804, $7000, $A82A;
  1409.     {$ENDC}
  1410. {
  1411.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1412.         This call is similar to OSADoScript except the initial command to
  1413.         execute comes in the form of an AppleEvent, and the result is an 
  1414.         AppleEvent reply record.  If the contextID defines any event handlers
  1415.         for that event, they are used to process the event.  If no event handler
  1416.         can be found in the context errAEEventNotHandled is returned.  If an
  1417.         event handler is found and the hander "continues" control onward, the
  1418.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1419.         called given the AppleEvent.  The result is returned in the form of an
  1420.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1421.         if the ResumeDispatchProc returns a reply event indicating an error,
  1422.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1423.         should never return errOSAScriptError).  Any error result returned by
  1424.         the ResumeDispatchProc will be returned by OSADoEvent.
  1425.     
  1426.         Errors:
  1427.             badComponentInstance    invalid scripting component instance
  1428.             errOSASystemError
  1429.             errOSAInvalidID
  1430.             errAEEventNotHandled:    no handler for event in contextID
  1431.     
  1432.         ModeFlags:
  1433.             kOSAModeNeverInteract
  1434.             kOSAModeCanInteract
  1435.             kOSAModeAlwaysInteract
  1436.             kOSAModeCantSwitchLayer
  1437.             kOSAModeDontReconnect
  1438.             kOSAModeDoRecord
  1439.     }
  1440. FUNCTION OSAMakeContext(scriptingComponent: ComponentInstance; {CONST}VAR contextName: AEDesc; parentContext: OSAID; VAR resultingContextID: OSAID): OSAError;
  1441.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1442.     INLINE $2F3C, $000C, $0805, $7000, $A82A;
  1443.     {$ENDC}
  1444. {
  1445.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1446.         Makes a new empty context which may be passed to OSAExecute or 
  1447.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1448.         created. If parentContext is kOSANullScript then the resulting context
  1449.         does not inherit bindings from any other context.
  1450.     
  1451.         Errors:
  1452.             badComponentInstance    invalid scripting component instance
  1453.             errOSASystemError
  1454.             errOSAInvalidID
  1455.             errAECoercionFail:        contextName is invalid
  1456.     }
  1457.  
  1458. {$ALIGN RESET}
  1459. {$POP}
  1460.  
  1461. {$SETC UsingIncludes := OSAIncludes}
  1462.  
  1463. {$ENDC} {__OSA__}
  1464.  
  1465. {$IFC NOT UsingIncludes}
  1466.  END.
  1467. {$ENDC}
  1468.